  document.write("<script language=javascript src='../js/validate.js'></script>");
  var app=angular.module('Login',['ngRoute'])
            app.config(['$routeProvider', function($routeProvider){
               	$routeProvider.when('/loginLocal', {
					templateUrl: 'loginLocal.html',
					controller: 'loginCtrl'
				});
            }]);
            app.controller("loginCtrl", function($scope,$location,$http,$window) {
            	
//          	var resultPath = 'http://sms2007.oicp.net:8080';
//							var resultPath = 'http://192.168.1.116:8080';
            	console.log(resultPath);
            	$scope.removeE = function(){
            		$(".has-feedback").removeClass("has-error")
            	}
            	$scope.getJson = function(resultPath,data,method,successfn){
            			$http({
            	                method: method, 
            	                dataType:"json",
            	                url: resultPath,
            	                data:data,
            	                headers: {
            	                	'Content-Type': 'application/json',
            	                	'token_id':'11',
            	                	'device_code':'WEB'
	         	                }
 						
            	            }).
            	            success(function(data) {
								successfn(data);
            	            }).
            	            error(function(data, status) {
//          	               console.log(data.msg);
            	            });
            		
            	}
            		//前往角色权限控制登录页
            	$scope.jumpToRoleAuthorityControl = function(){
            			window.location.href= 'tenantLogin.html';
            	}
            	$scope.user = {}
            	$scope.login = function(){
            		if($scope.user.login_user == undefined || $scope.user.login_password == undefined){
            			return
            		}else{
            			console.log(resultPath);
            			//$scope.getJson('http://192.168.1.125/localserv/v1/auths/login',$scope.user,'post',function(data){
            			//$scope.getJson('http://192.168.1.116/wisdomeatery/localserv/v1/auths/login',$scope.user,'post',function(data){
            				$scope.getJson(resultPath+'/wisdomeatery/localserv/v1/auths/login',$scope.user,'post',function(data){
            				
            				console.log(data)
            				if(data.code == 0){
            					var storage=window.sessionStorage;
					            //写入token_id字段
					            storage["token_id"]=data.data.token_id;
					            //设施session时效
//					            storage.setMaxInactiveInterval(1800);  //30min
					            //跳转界面
//					            window.location="/SmartCanteen/html/main.html#/corporation";
//					            window.location="/SmartCanteen/WebContent/html/main.html#/corporation";
												window.location.href = 'main.html';
					        }else{
            					$('.alert').fadeIn('slow')
		            			setTimeout("$('.alert').fadeOut('slow')",3000);
		            			$(".has-feedback").addClass("has-error")
            				}
            			})
            		}
            	}
            	$scope.test = function(){
            		let file = $('#uiui').get(0).files[0];
            		var storage=window.sessionStorage;
	           		let token_id=storage.token_id;
            		console.log(token_id)
				        let fd = new FormData();
				        fd.append('file', file); 
				        $http({
				              method:'POST',
				              url:"http://192.168.1.125/v1/base_system/file/upload",
				              data: fd,
				              
				              headers: {
				              	'token_id':token_id,
				              	'Content-Type':undefined
				              },
				              transformRequest: angular.identity 
				        })   
				        .success( function ( data ){
				            console.log(data)
				            console.log(fd)
				        }); 
				
				   
            	}
            });

